export const RandomCode = {
	code: (strlenght) => {
		const alphabet =
			"qwert1yuiopa8sdfghjkl5zxcv2bn7mQWERT6YUIO4PASDF0GH3JKLZXCVBNM9";
		// 生成的字符串固定长度
		let left = "";
		for (var i = 0; i < strlenght; i++) {
			//    right = right + (min + (Random().nextInt(max - min))).toString();
			left = left + alphabet[Math.floor(Math.random() * alphabet.length)];
		}
		return left;
	},
};

export const urlsafe_b64encode = (base64Str) => {
	return base64Str
		.replace(/\+/g, "-") // Convert '+' to '-'
		.replace(/\//g, "_"); // Convert '/' to '_'
	// .replace(/=+$/, '');
};

export const startUrlFh = (urlTemp) => {
	if (!urlTemp.includes("?")) return "?";
	if (urlTemp.endsWith("?") || urlTemp.endsWith("&")) return "";
	return "&";
}